$(document).ready(function(){
      var searchInfo={
          province:"",//省份
          city:"",//城市
          area:"",//区
          type:"",//小区类别
          status:"",//物业服务状态
          keyword:""//关键词
      };
			var table=$("#communityTable");
			var t=table.dataTable({
        "ajax":function(data,callback,setting){
          var page = table.api().page.info();
          $.post("/index.php?m=Admin&c=Community&a=search",{pageIndex:page.page+1,pageSize:page.length,select:searchInfo.keyword},function(data,status){
            console.log(data);
              callback(data); 
          });
        },

 				"pageLength":10,
  				"ordering":false,
          "deferRender": true,
  				"columns":[
  				{"data":"id"},
          {"data":"id"},
  				{"data":"no"},
  				{"data":"name"},
  				{"data":"full_parent_name"},//小区地址
  				{"data":"type"},
  				{"data":"inSvr"},//物业情况
  				{"data":"id"},
  				],
  				"columnDefs":[
  				{
  					"targets":0,
  					"data":"id",
  					"render":function(data,type,full,meta){
  						return '<input type="checkbox" value="'+data+'" name="community_id">';
  					}
  				},
          {
            "targets":6,
            "data":"inSvr",
            "render":function(data,type,full,meta){
              switch(data){
                case '正在服务':
                  return '<span class="c-success">正在服务</span>';
                  break;
                case '停止服务':
                  return '<span class="c-red">停止服务</span>';
                  break;
                case '准备入驻':
                  return '<span class="c-warning">准备入驻</span>';
                  break;
              }
            }
          },
  				{
  					"targets":7,
  					"data":"id",
  					"render":function(data,type,full,meta){
  						var poStr='<a href="javascript:;" uid="'+data+'" class="label label-success radius zoneBtn">园区管理</a><a title="编辑" href="javascript:;" uid="'+data+'" class="ml-5 communityEdit" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a><a title="删除" href="javascript:;" uid="'+data+'" class="ml-5 communityDel uid-'+data+'" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>';
  						return poStr;
  					}

  				},
  				],
  			"fnCreatedRow":function(row,data,index){
  				//row 表示当前tr，data表示当前行的元素对象，index表示当前tr索引
  			},
			"bPaginate": true, //翻页功能
			// "processing": true,
      "searching":false,
      "serverSide": true,//服务器模式
        });
$(".searchButton").click(function(){
      searchInfo.keyword=$("#searchName").val();
      t.api().draw();
    });
    // 回车事件
    // document.onkeydown = function(e){
    //              var ev = document.all ? window.event : e;
    //              if(ev.keyCode==13) {
    //                 e.preventDefault();
    //                 searchInfo.keyword=$("#searchName").val();
    //                 t.api().draw();
    //              }
    //         }
});